/*pr0tUH1dV1X/xaCwJNPKCG5f7UZ77rStGsiD5kJnQECcKqMOm5PIpeX/OtXTrHAH*/
/*
 * @Author: xiahui 
 * @PageInfo: 卡片取消 
 * @Date: 2019-01-15 19:47:32 
 * @Last Modified by: guoylei
 * @Last Modified time: 2021-09-28 09:39:09
 */
import { AREA, URL, UISTATUS, FIELDS, DATASOURCECACHE, PAGECODE } from '../../constance';
import { getDefData, setDefData } from '../../../../../scmpub/scmpub/pub/cache';
import { showCancelDialog } from '../../../../../scmpub/scmpub/pub/tool/messageUtil';
import { getCurrentLastId } from '../../../../../scmpub/scmpub/pub/cache';
import pageInfoClick from './pageInfoClick';

export default function(props) {
	showCancelDialog({
		beSureBtnClick: () => {
			let source = props.getUrlParam('source'); // 来源页
			let status = props.getUrlParam('status');
			if (status == UISTATUS.ref20 || status == UISTATUS.ref28) {
				let pagecode = status == UISTATUS.ref20 ? PAGECODE.ref20Pagecode : PAGECODE.ref28Pagecode;
				if (props.transferTable.getTransformFormAmount(AREA.cardLeftId) == 1) {
					// 转单-剩一条时，返回上级页面
					window.onbeforeunload = null;
					props.pushTo(source, { pagecode: pagecode });
				} else {
					// 转单-多条，取消固定写法
					props.transferTable.setTransformFormStatus(AREA.cardLeftId, {
						status: false,
						onChange: (current, next) => {}
					});
				}
			} else {
				let id = props.getUrlParam('id');
				props.setUrlParam({ status: UISTATUS.browse });
				//是否暂存取消
				let tempsave = getDefData(DATASOURCECACHE.tempCardCacheKey, 'tempsave');
				if (status == UISTATUS.add || tempsave) {
					// 新增
					let pk = id ? id : getCurrentLastId(DATASOURCECACHE.dataSourceListCacheKey);
					pageInfoClick.call(this, props, pk);
					// props.resMetaAfterPkorgEdit();
				} else {
					let pk = props.form.getFormItemsValue(AREA.cardFormId, FIELDS.pk_ct_pu).value;
					pageInfoClick.call(this, props, pk ? pk : id, true, true);
				}
				setDefData(DATASOURCECACHE.tempCardCacheKey, 'tempsave', false);
			}
		}
	});
}

/*pr0tUH1dV1X/xaCwJNPKCG5f7UZ77rStGsiD5kJnQECcKqMOm5PIpeX/OtXTrHAH*/